﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace MONTRASEC_test.Management
{
  public partial class Register : System.Web.UI.Page
  {
    protected void Page_Load_from_template(object sender, EventArgs e)
    {
      if (!Page.IsPostBack)
      {

        // Bind the users and roles 
        //BindUsersToUserList();
        BindRolesToList();
        // Check the selected user's roles 
        //CheckRolesForSelectedUser();
      }

    }

    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
      TextBox UserCountry = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("tbUserCountry");
      RadioButton UserLevel = (RadioButton)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("rbUserLevel");
      TextBox UserEMAIL = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email");
      TextBox UserFirstname = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("tbUserFirstname");
      TextBox UserLastname = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("tbUserLastname");
      TextBox UserUsername = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
      sdsUser.InsertParameters.Clear();
      sdsUser.InsertParameters.Add("USER_USER_FIRSTNAME", UserFirstname.Text);
      sdsUser.InsertParameters.Add("USER_USER_LASTNAME", UserLastname.Text);
      sdsUser.InsertParameters.Add("USER_USER_COUNTRY", UserCountry.Text);
     //  sdsUser.InsertParameters.Add("USER_USER_LEVEL", UserLevel.Text);
      sdsUser.InsertParameters.Add("USER_USER_EMAIL", UserEMAIL.Text);
      sdsUser.InsertParameters.Add("USER_USER_USERNAME", UserUsername.Text);
      sdsUser.Insert();
    }



    private void BindRolesToList()
    {
      Repeater UsersRoleList = (Repeater)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UsersRoleList");
      // Get all of the roles 
      string[] roles = Roles.GetAllRoles();
      UsersRoleList.DataSource = roles;
      UsersRoleList.DataBind();
    }
  }
}
